import { ShopItemManager } from "./ShopItemManager";
import { GameManager } from "./GameManager";

const { ccclass, property } = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    @property(cc.Prefab)
    explodePrefab: cc.Prefab;

    hookItem: cc.Node;

    start() {
        this.node.on(cc.Node.EventType.TOUCH_START, this.explodeThings, this, true);
    }

    /**
     * 炸掉拉到的东西
     */
    public explodeThings() {
        let gameManager = GameManager.Instance(GameManager);
        this.hookItem = gameManager.hookItem;
        gameManager.catchItem = null;
        ShopItemManager.Instance(ShopItemManager).reduceBombCount();
        ShopItemManager.Instance(ShopItemManager).refreshDisplay();
        this.hookItem.removeAllChildren();
        let particle = cc.instantiate(this.explodePrefab);
        particle.parent = this.hookItem;
        particle.setPosition(cc.v2(0, 0))
        gameManager.ropeSpeed = gameManager.normalRopeSpeed;
        gameManager.ropeState = gameManager.ROPE_STATE.REDUCE;
    }
}
